

package com.flashbsm.model
{
	import mx.collections.ArrayCollection;
	import flash.events.Event;
	import mx.controls.Alert;
	import com.flashbsm.events.*;

	public class fbsmModel
	{
		private static var instance:fbsmModel;

		public static const VIEWING_NORMAL:String = "normal";
		public static const VIEWING_SHOWALL:String = "showAll";

		[Bindable]
		public var categItems:ArrayCollection = new ArrayCollection();

		[Bindable]
		public var pluginItems:ArrayCollection = new ArrayCollection();

		static public var categories:communicate = new communicate();
		static public var plugins:communicate = new communicate();
		

		public function fbsmModel()
		{
			
			categories.theType="getCategInfo";
			categories.getInfo();
			categories.theTarget = categItems;
			categories.addEventListener("gotData", giveData);
			

			
			plugins.theType="getPluginInfo";
			plugins.getInfo();
			plugins.theTarget = pluginItems;
			plugins.addEventListener("gotData", giveData);
			
			if( instance != null )
			{
				throw( new Error( "there can be only one instance of ChatModel" ) );
			}
		}
		public function giveData(event:gotDataEvent):void
		{
			event.theTarget.source = event.target.theResult;
		}


		public static function getInstance():fbsmModel
		{
			if( instance == null )
			{

				instance = new fbsmModel();
			}

			return instance;
		}
	}
}
